 <%--
 *  File:  FileListRuleMainEdit.jsp
 *  Desc:	
 *
 *  Date	  :	 2010/07/22      		    
 *  Author	:  kenfang	
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "E0513";
  String strModuleName = "CFM";
  String contextPath = request.getContextPath();
  String strFlag=request.getParameter("displayflag");
%>
<%@ include file="/inc/CommonHeader.inc" %>

<html>
<head>
<title>FileListRuleMainEdit</title>
<PageFlow:CheckPageFlow pageName="p_columnmappingrulemain"/>
<%@ include file="/inc/CatchError.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<%@ include file="/inc/NewCalendar.inc" %>
<%

	HashMap columnmappingrulehash = (HashMap)pageContext.getAttribute("columnmappingrule");
	String checked = "checked";
	String disabled = "";
	if(columnmappingrulehash == null){
		columnmappingrulehash = new HashMap();
	}else {
		String isstander = (String)columnmappingrulehash.get("isstander");
		if(isstander.equals("N")){
			checked = "";
		}
	}
	
	if(strFlag.equals("view")){
		disabled = "disabled";
		
	}
	Integer columnmappingruleid = (Integer)columnmappingrulehash.get("columnmappingruleid");
	boolean hasId = !(columnmappingruleid==null);
%>
<%--  edit page related functions   --%>
<%if(!isView){%><script language="JavaScript">

function page_save()
{
   if(!checkForm(cform))   return;
	var flag = document.cform.standerflag;
	if(flag.checked){
		document.cform.isstander.value='Y'
	}else {
		document.cform.isstander.value='N'
	}
	cform.actionname.value = "save";
	cform.target = "_parent";
	isRunning = true;
	cform.submit();
}
</script><%}%>

<%--  other functions   --%>
<script language="JavaScript">
function hasHeader(){
	var rowcountspan = document.getElementById("rowcount");
	var hasheader = document.cform.hasheader.value;
	if(hasheader == 1){
		rowcountspan.style.display='inline';
		document.cform.headerlinecount.command='positive';
	}else{
		document.cform.headerlinecount.value='';
		rowcountspan.style.display='none';
		document.cform.headerlinecount.command='';
	}
}
function page_back(){
	parent.location.href="FileListRuleSummary.jsp?<%=OvalTools.randomURL()%>";
}
function getTableName(){
	document.cform.tablename.value = "";
	if(document.cform.filedatatype.value == " ")
	  return;
	var  datahandler = new  DataHandler() ;
	datahandler.add_params("processtype" , document.cform.filedatatype.value,"Integer");
	datahandler.getResult("tablename","document.cform.tablename"); 
	datahandler.getResult("datatype","document.cform.datatype"); 
	datahandler.add_job("j_gettablename") ;
	datahandler.add_function("changeStanderflag()");
	datahandler.runDataHandler ();
}

function changeStanderflag(){
	var datatype = document.cform.datatype.value;
	if(datatype == "M"){
		document.cform.standerflag.checked = true;
		document.cform.standerflag.disabled = "disabled";
		parent.up.document.getElementById('A03').style.display = 'none';
	}else{
		document.cform.standerflag.disabled = "";
	}
}

function checkchange(){
	var standerflag = document.cform.standerflag;
	if(!parent.up.document.getElementById('A03')){
		window.location.reload();
	}
	if(standerflag.checked){
		parent.up.document.getElementById('A03').style.display = 'none';
	}else {
		parent.up.document.getElementById('A03').style.display = 'block';
	}
}

function setReadonly(){
	//var displayflag = '<%=strFlag %>';
	if (document.cform.columnmappingruleid){
		//document.cform.columnmappingrulename.disabled = "disabled";
		document.cform.filedatatype.disabled = "disabled";
	}else {
		document.cform.startline.value = "2";
		document.cform.workflowname.value = "import";
	}
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow: auto;">
<iframe name="reloadHandler" style="display:none" ></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_columnmappingrulemain">
    <input type="hidden" name="actionname">
    <input type="hidden" name="flag">
    <custom:hidden property="datatype"/>

<table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tr>
    <td valign=top>
      <table border=0 cellpadding=1 cellspacing=0 width="100%">
        <tr>
          <td bgcolor=#000000 style="PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 0px">
            <table bgcolor=#000000 border=0 cellpadding=0 cellspacing=0 width="100%">
              <tr>
                <td  bgcolor=#ffffff style="PADDING-BOTTOM: 3px; PADDING-LEFT: 3px; PADDING-RIGHT: 3px; PADDING-TOP: 3px" valign="top">
                  <div id=div2 style="HEIGHT: 415px; OVERFLOW: auto;">
                    <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">

<%--    top function buttons    --%>
<% if(!isView){%>
                      <tr>
                        <td colspan="4" class="td_right" height="18">
                          <a onclick="page_save()"><custom:button type="2" label="L_Save" imgsrc="save_btn.gif" border="0" /></a>
                        </td>
                      </tr>
<%}%>

                      <tr>
                        <td width="150" class="<%=needClass%>" id="autocode"> <%=label.getLabelName("L_ColumnMappingCode")+label.getLabelName("L_Colon")%></td>
                        <td width="300"> 
                        <%if(columnmappingruleid == null){ %>
                        <custom:text style="border:1px #7F9DB9 solid;" name="columnmappingrule" property="columnmappingrulecode" size="20" command="notnull"  label="L_ColumnMappingCode" />
                        <%}else{ %>
                        <custom:write property="columnmappingrulecode" name="columnmappingrule"/>
                        <%} %>
                        </td>
                        <td width="150" class="<%=needClass%>" ><%=label.getLabelName("L_ColumnMappingName")+label.getLabelName("L_Colon")%></td>
                        <td> <custom:text style="border:1px #7F9DB9 solid;" name="columnmappingrule" property="columnmappingrulename" size="20" command="notnull"  label="L_ColumnMappingName"/></td>
                      </tr>
                      <tr> 
				          <td class="<%=needClass%>" width="150">&nbsp;<%= label.getLabelName("L_TransType") %><%= label.getLabelName("L_Colon") %></td>
				          <td>
				            <custom:selectdic disabled="<%=isView %>" defaultValueCost=" " onchange="getTableName()"  name="columnmappingrule" property="filedatatype" dictType="DataCleanType" />
				          </td>
				          <td class="td-text" width="150">&nbsp;<%= label.getLabelName("L_TableName") %><%= label.getLabelName("L_Colon") %></td>
				          <td>
				            <custom:text property="tablename" name="columnmappingrule" size="20" style="border:0" readonly="true" />
				          </td>
				        </tr>
                      <tr>
                        <td class="td-text">&nbsp;<%=label.getLabelName("L_IsStander")+label.getLabelName("L_Colon")%></td>
                        <td >
                        	<input type="checkbox" value="" class="normalradio" name="standerflag" <%=checked %> <%=disabled %> onClick="checkchange()">
                        	<input type="hidden" name="isstander">
                        </td>
                        
                        <td  class="<%=needClass%>" ><%=label.getLabelName("L_WorkflowName")+label.getLabelName("L_Colon")%></td>
                        <td> <custom:text style="border:1px #7F9DB9 solid;" name="columnmappingrule" property="workflowname" size="20" command="notnull" label="L_WorkflowName"  /> </td>
                      </tr>
                      
                      <tr>
                        <td class="<%=needClass%>">&nbsp;<%=label.getLabelName("L_StartLine")+label.getLabelName("L_Colon")%></td>
                        <td >
                        	<custom:text style="border:1px #7F9DB9 solid;" name="columnmappingrule" property="startline" size="20" command="notnull" label="L_StartLine"/>
                        </td>
                        
                        <td  class="td-text" >&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                     
                     
  
<%--    form hidden elements    --%>
                      <tr>
                        <td style="display:none">
                        <%
                         
                         if("new".equals(strFlag)){
                        %>
                        <input type="hidden" name="status" value="10"/>
                        <custom:hidden name="userinfo" property="orgid" scope="session"/>
                        
            	            <%}else{%>
            	            <custom:hidden name="columnmappingrule" property="columnmappingruleid" />
            	            <%}%>
                        </td>
                      </tr>

                    </table>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
         <tr><td class="summary_top"></td></tr>
         <tr>
           <td class="td_center">
          
             <a onclick="page_back();"><custom:button type="1" label="L_Back" imgsrc="new.gif" border="0" style="width:60"/></a>
          
           </td>
         </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
<script>
	checkchange();
	<%if(!strFlag.equals("view")){%>
		setReadonly();
		getTableName();
	<%}%>
</script>
</html>